package com.galaxy.nebula.account.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.galaxy.nebula.account.model.Account;
import com.galaxy.nebula.account.service.IAccountService;

/**
 * @author ChenKai
 * @createDate 2011-12-18
 */
@Controller
public class AccountController {

    private IAccountService accountServiceImpl;

    @Autowired
    public void setAccountServiceImpl(IAccountService accountServiceImpl) {
        this.accountServiceImpl = accountServiceImpl;
    }
    
    @RequestMapping("/account/detail.html")
    public String account() {
        return "/pages/account/detail.jsp";
    }

    @RequestMapping("/account/createAccount.html")
    public String createAccount(ModelMap modelMap, Account account) {
        Account savedAccount = accountServiceImpl.createAccount(account);
        modelMap.put("account", savedAccount);
        return "/pages/account/detail.jsp";
    }

    @RequestMapping("/account/accountDetail.html")
    public String accountDetail(ModelMap modelMap, Long accountId) {
        Account account = accountServiceImpl.getAccountById(accountId);
        modelMap.put("account", account);
        return "/pages/account/detail.jsp";
    }

}
